home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DJGPP / BNU22SR1.ZIP / src / binutils.2 / bfd / elf32-hp.c < prev    next >
C/C++ Source or Header  |  1993-05-30  |  47KB  |  1,500 lines

  1. /* BFD back-end for HP PA-RISC ELF files.
  2.    Copyright (C) 1990-1991 Free Software Foundation, Inc.
  3.  
  4.    Written by
  5.     
  6.     Center for Software Science
  7.     Department of Computer Science
  8.     University of Utah
  9.  
  10. This file is part of BFD, the Binary File Descriptor library.
  11.  
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2 of the License, or
  15. (at your option) any later version.
  16.  
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with this program; if not, write to the Free Software
  24. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  25.  
  26. #include "bfd.h"
  27. #include "sysdep.h"
  28. #include "libbfd.h"
  29. #include "obstack.h"
  30. #include "libelf.h"
  31.  
  32. /* ELF32/HPPA relocation support
  33.  
  34.     This file contains ELF32/HPPA relocation support as specified
  35.     in the Stratus FTX/Golf Object File Format (SED-1762) dated
  36.     November 19, 1992.
  37. */
  38.  
  39. /*
  40.     Written by:
  41.     
  42.     Center for Software Science
  43.     Department of Computer Science
  44.     University of Utah
  45. */
  46.  
  47. #include "elf32-hppa.h"
  48.  
  49. /* ELF/PA relocation howto entries */
  50.  
  51. static bfd_reloc_status_type hppa_elf_reloc();
  52.  
  53. reloc_howto_type elf_hppa_howto_table[ELF_HOWTO_TABLE_SIZE] = {
  54.     /*  'bitpos' and 'abs' are obsolete */
  55.     /* type            rs sz bsz pcrel  bpos abs    ovrf  sf           name */
  56.     /* 9.3.4. Address relocation types */
  57.     { R_HPPA_NONE,        0, 3, 19, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_NONE"},
  58.     { R_HPPA_32,        0, 3, 32, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_32"    },
  59.     { R_HPPA_11,        0, 3, 11, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_11"    },
  60.     { R_HPPA_14,        0, 3, 14, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_14"    },
  61.     { R_HPPA_17,        0, 3, 17, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_17"    },
  62.     { R_HPPA_L21,        0, 3, 21, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_L21"    },
  63.     { R_HPPA_R11,        0, 3, 11, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_R11"    },
  64.     { R_HPPA_R14,        0, 3, 14, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_R14"    },
  65.     { R_HPPA_R17,        0, 3, 17, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_R17"    },
  66.     { R_HPPA_LS21,        0, 3, 21, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_LS21"    },
  67.     { R_HPPA_RS11,        0, 3, 11, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_RS11"    },
  68.     { R_HPPA_RS14,        0, 3, 14, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_RS14"    },
  69.     { R_HPPA_RS17,        0, 3, 17, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_RS17"    },
  70.     { R_HPPA_LD21,        0, 3, 21, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_LD21"    },
  71.     { R_HPPA_RD11,        0, 3, 11, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_RD11"    },
  72.     { R_HPPA_RD14,        0, 3, 14, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_RD14"    },
  73.     { R_HPPA_RD17,        0, 3, 17, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_RD17"    },
  74.     { R_HPPA_LR21,        0, 3, 21, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_LR21"    },
  75.     { R_HPPA_RR14,        0, 3, 14, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_RR14"    },
  76.     { R_HPPA_RR17,        0, 3, 17, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_RR17"    },
  77.     /* 9.3.5. GOTOFF address relocation types        */
  78.     { R_HPPA_GOTOFF_11,    0, 3, 11, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_GOTOFF_11"    },
  79.     { R_HPPA_GOTOFF_14,    0, 3, 14, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_GOTOFF_14"    },
  80.     { R_HPPA_GOTOFF_L21,    0, 3, 21, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_GOTOFF_L21"    },
  81.     { R_HPPA_GOTOFF_R11,    0, 3, 11, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_GOTOFF_R11"    },
  82.     { R_HPPA_GOTOFF_R14,    0, 3, 14, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_GOTOFF_R14"    },
  83.     { R_HPPA_GOTOFF_LS21,    0, 3, 21, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_GOTOFF_LS21"    },
  84.     { R_HPPA_GOTOFF_RS11,    0, 3, 11, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_GOTOFF_RS11"    },
  85.     { R_HPPA_GOTOFF_RS14,    0, 3, 14, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_GOTOFF_RS14"    },
  86.     { R_HPPA_GOTOFF_LD21,    0, 3, 21, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_GOTOFF_LD21"    },
  87.     { R_HPPA_GOTOFF_RD11,    0, 3, 11, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_GOTOFF_RD11"    },
  88.     { R_HPPA_GOTOFF_RD14,    0, 3, 14, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_GOTOFF_RD14"    },
  89.     { R_HPPA_GOTOFF_LR21,    0, 3, 21, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_GOTOFF_LR21"    },
  90.     { R_HPPA_GOTOFF_RR14,    0, 3, 14, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_GOTOFF_RR14"    },
  91.     /* 9.3.6. Absolute call relocation types    */
  92.     { R_HPPA_ABS_CALL_11,    0, 3, 11, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_ABS_CALL_11"    },
  93.     { R_HPPA_ABS_CALL_14,    0, 3, 14, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_ABS_CALL_14"    },
  94.     { R_HPPA_ABS_CALL_17,    0, 3, 17, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_ABS_CALL_17"    },
  95.     { R_HPPA_ABS_CALL_L21,    0, 3, 21, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_ABS_CALL_L21"    },
  96.     { R_HPPA_ABS_CALL_R11,    0, 3, 11, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_ABS_CALL_R11"    },
  97.     { R_HPPA_ABS_CALL_R14,    0, 3, 14, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_ABS_CALL_R14"    },
  98.     { R_HPPA_ABS_CALL_R17,    0, 3, 17, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_ABS_CALL_R17"    },
  99.     { R_HPPA_ABS_CALL_LS21,    0, 3, 21, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_ABS_CALL_LS21"    },
  100.     { R_HPPA_ABS_CALL_RS11,    0, 3, 11, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_ABS_CALL_RS11"    },
  101.     { R_HPPA_ABS_CALL_RS14,    0, 3, 14, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_ABS_CALL_RS14"    },
  102.     { R_HPPA_ABS_CALL_RS17,    0, 3, 17, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_ABS_CALL_RS17"    },
  103.     { R_HPPA_ABS_CALL_LD21,    0, 3, 21, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_ABS_CALL_LD21"    },
  104.     { R_HPPA_ABS_CALL_RD11,    0, 3, 11, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_ABS_CALL_RD11"    },
  105.     { R_HPPA_ABS_CALL_RD14,    0, 3, 14, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_ABS_CALL_RD14"    },
  106.     { R_HPPA_ABS_CALL_RD17,    0, 3, 17, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_ABS_CALL_RD17"    },
  107.     { R_HPPA_ABS_CALL_LR21,    0, 3, 21, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_ABS_CALL_LR21"    },
  108.     { R_HPPA_ABS_CALL_RR14,    0, 3, 14, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_ABS_CALL_RR14"    },
  109.     { R_HPPA_ABS_CALL_RR17,    0, 3, 17, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_ABS_CALL_RR17"    },
  110.     /* 9.3.7. PC-relative call relocation types    */
  111.     { R_HPPA_PCREL_CALL_11,    0, 3, 11, true,  0,   false, true, hppa_elf_reloc, "R_HPPA_PCREL_CALL_11"    },
  112.     { R_HPPA_PCREL_CALL_14,    0, 3, 14, true,  0,   false, true, hppa_elf_reloc, "R_HPPA_PCREL_CALL_14"    },
  113.     { R_HPPA_PCREL_CALL_17,    0, 3, 17, true,  0,   false, true, hppa_elf_reloc, "R_HPPA_PCREL_CALL_17"    },
  114.     { R_HPPA_PCREL_CALL_L21,0, 3, 21, true,  0,   false, true, hppa_elf_reloc, "R_HPPA_PCREL_CALL_L21"    },
  115.     { R_HPPA_PCREL_CALL_R11,0, 3, 11, true,  0,   false, true, hppa_elf_reloc, "R_HPPA_PCREL_CALL_R11"    },
  116.     { R_HPPA_PCREL_CALL_R14,0, 3, 14, true,  0,   false, true, hppa_elf_reloc, "R_HPPA_PCREL_CALL_R14"    },
  117.     { R_HPPA_PCREL_CALL_R17,0, 3, 17, true,  0,   false, true, hppa_elf_reloc, "R_HPPA_PCREL_CALL_R17"    },
  118.     { R_HPPA_PCREL_CALL_LS21,0,3, 21, true,  0,   false, true, hppa_elf_reloc, "R_HPPA_PCREL_CALL_LS21"    },
  119.     { R_HPPA_PCREL_CALL_RS11,0,3, 11, true,  0,   false, true, hppa_elf_reloc, "R_HPPA_PCREL_CALL_RS11"    },
  120.     { R_HPPA_PCREL_CALL_RS14,0,3, 14, true,  0,   false, true, hppa_elf_reloc, "R_HPPA_PCREL_CALL_RS14"    },
  121.     { R_HPPA_PCREL_CALL_RS17,0,3, 17, true,  0,   false, true, hppa_elf_reloc, "R_HPPA_PCREL_CALL_RS17"    },
  122.     { R_HPPA_PCREL_CALL_LD21,0,3, 21, true,  0,   false, true, hppa_elf_reloc, "R_HPPA_PCREL_CALL_LD21"    },
  123.     { R_HPPA_PCREL_CALL_RD11,0,3, 11, true,  0,   false, true, hppa_elf_reloc, "R_HPPA_PCREL_CALL_RD11"    },
  124.     { R_HPPA_PCREL_CALL_RD14,0,3, 14, true,  0,   false, true, hppa_elf_reloc, "R_HPPA_PCREL_CALL_RD14"    },
  125.     { R_HPPA_PCREL_CALL_RD17,0,3, 17, true,  0,   false, true, hppa_elf_reloc, "R_HPPA_PCREL_CALL_RD17"    },
  126.     { R_HPPA_PCREL_CALL_LR21,0,3, 21, true,  0,   false, true, hppa_elf_reloc, "R_HPPA_PCREL_CALL_LR21"    },
  127.     { R_HPPA_PCREL_CALL_RR14,0,3, 14, true,  0,   false, true, hppa_elf_reloc, "R_HPPA_PCREL_CALL_RR14"    },
  128.     { R_HPPA_PCREL_CALL_RR17,0,3, 17, true,  0,   false, true, hppa_elf_reloc, "R_HPPA_PCREL_CALL_RR17"    }, /* #69 */
  129.  
  130.     /* 9.3.8. Plabel relocation types */
  131.     { R_HPPA_PLABEL_32,    0, 3, 32, true,  0,   false, true, hppa_elf_reloc, "R_HPPA_PLABEL_32"    },
  132.     { R_HPPA_PLABEL_11,    0, 3, 11, true,  0,   false, true, hppa_elf_reloc, "R_HPPA_PLABEL_11"    },
  133.     { R_HPPA_PLABEL_14,    0, 3, 14, true,  0,   false, true, hppa_elf_reloc, "R_HPPA_PLABEL_14"    },
  134.     { R_HPPA_PLABEL_L21,    0, 3, 21, true,  0,   false, true, hppa_elf_reloc, "R_HPPA_PLABEL_L21"    },
  135.     { R_HPPA_PLABEL_R11,    0, 3, 11, true,  0,   false, true, hppa_elf_reloc, "R_HPPA_PLABEL_R11"    },
  136.     { R_HPPA_PLABEL_R14,    0, 3, 14, true,  0,   false, true, hppa_elf_reloc, "R_HPPA_PLABEL_R14"    },    /* 75 */
  137.  
  138.     /* 9.3.9. Data linkage table (DLT) relocation types    */
  139.     { R_HPPA_DLT_32,    0, 3, 32, true,  0,   false, true, hppa_elf_reloc, "R_HPPA_DLT_32"    },
  140.     { R_HPPA_DLT_11,    0, 3, 11, true,  0,   false, true, hppa_elf_reloc, "R_HPPA_DLT_11"    },
  141.     { R_HPPA_DLT_14,    0, 3, 14, true,  0,   false, true, hppa_elf_reloc, "R_HPPA_DLT_14"    },
  142.     { R_HPPA_DLT_L21,    0, 3, 21, true,  0,   false, true, hppa_elf_reloc, "R_HPPA_DLT_L21"    },
  143.     { R_HPPA_DLT_R11,    0, 3, 11, true,  0,   false, true, hppa_elf_reloc, "R_HPPA_DLT_R11"    },
  144.     { R_HPPA_DLT_R14,    0, 3, 14, true,  0,   false, true, hppa_elf_reloc, "R_HPPA_DLT_R14"    },    /* 81 */
  145.  
  146.     /* 9.3.10. Relocations for unwinder tables    */
  147.     { R_HPPA_UNWIND_ENTRY,    0, 3, 32, true,  0,   false, true, hppa_elf_reloc, "R_HPPA_UNWIND_ENTRY"},
  148.     { R_HPPA_UNWIND_ENTRIES,0, 3, 32, true,  0,   false, true, hppa_elf_reloc, "R_HPPA_UNWIND_ENTRIES"},    /* 83 */
  149.  
  150.     { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, /* 84-89 */
  151.     { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, /* 90-99 */
  152.     { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, /* 100-109 */
  153.     { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, /* 110-119 */
  154.     { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 },            /* 120-127 */
  155.     
  156.     /*  9.3.11. Relocation types for complex expressions    */
  157.     { R_HPPA_PUSH_CONST,    0, 3, 32, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_PUSH_CONST"    },
  158.     { R_HPPA_PUSH_SYM,    0, 3, 32, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_PUSH_SYM"    },
  159.     { R_HPPA_PUSH_GOT,    0, 3, 32, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_PUSH_GOT"    },
  160.     { R_HPPA_PUSH_PC,    0, 3, 32, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_PUSH_PC"    },
  161.     { R_HPPA_PUSH_PROC,    0, 3, 32, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_PUSH_PROC"    },
  162.     { R_HPPA_PUSH_PLABEL,    0, 3, 32, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_PUSH_PLABEL"    },
  163.     { R_HPPA_MAX,        0, 3, 32, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_MAX"    },
  164.     { R_HPPA_MIN,        0, 3, 32, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_MIN"    },
  165.     { R_HPPA_ADD,        0, 3, 32, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_ADD"    },
  166.     { R_HPPA_SUB,        0, 3, 32, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_SUB"    },
  167.     { R_HPPA_MULT,        0, 3, 32, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_MULT"    },
  168.     { R_HPPA_DIV,        0, 3, 32, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_DIV"    },
  169.     { R_HPPA_MOD,        0, 3, 32, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_MOD"    },
  170.     { R_HPPA_AND,        0, 3, 32, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_AND"    },
  171.     { R_HPPA_OR,        0, 3, 32, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_OR"    },
  172.     { R_HPPA_XOR,        0, 3, 32, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_XOR"    },
  173.     { R_HPPA_NOT,        0, 3, 32, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_NOT"    },
  174.     { R_HPPA_LSHIFT,    0, 3, 32, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_LSHIFT"    },
  175.     { R_HPPA_ARITH_RSHIFT,    0, 3, 32, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_ARITH_RSHIFT"    },
  176.     { R_HPPA_LOGIC_RSHIFT,    0, 3, 32, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_LOGIC_RSHIFT"    },
  177.     { R_HPPA_EXPR_F,    0, 3, 32, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_L"    },
  178.     { R_HPPA_EXPR_L,        0, 3, 32, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_EXPR_L"    },
  179.     { R_HPPA_EXPR_R,        0, 3, 32, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_EXPR_R"    },
  180.     { R_HPPA_EXPR_LS,        0, 3, 32, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_EXPR_LS"    },
  181.     { R_HPPA_EXPR_RS,        0, 3, 32, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_EXPR_RS"    },
  182.     { R_HPPA_EXPR_LD,        0, 3, 32, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_EXPR_LD"    },
  183.     { R_HPPA_EXPR_RD,        0, 3, 32, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_EXPR_RD"    },
  184.     { R_HPPA_EXPR_LR,        0, 3, 32, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_EXPR_LR"    },
  185.     { R_HPPA_EXPR_RR,        0, 3, 32, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_EXPR_RR"    },
  186.  
  187.     { R_HPPA_EXPR_32,    0, 3, 32, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_EXPR_32"    },
  188.     { R_HPPA_EXPR_21,    0, 3, 21, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_EXPR_21"    },
  189.     { R_HPPA_EXPR_11,    0, 3, 11, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_EXPR_11"    },
  190.     { R_HPPA_EXPR_14,    0, 3, 14, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_EXPR_14"    },
  191.     { R_HPPA_EXPR_17,    0, 3, 17, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_EXPR_17"    },
  192.     { R_HPPA_EXPR_12,    0, 3, 12, false, 0,   false, true, hppa_elf_reloc, "R_HPPA_EXPR_12"    },
  193.     { R_HPPA_UNIMPLEMENTED, 0, 0,  0, false, 0,   false, false,NULL,       "R_HPPA_UNIMPLEMENTED"},    /* 163 */
  194. };
  195.  
  196. static unsigned long
  197. DEFUN(hppa_elf_rebuild_insn, (abfd,insn,value,r_type,r_field, r_format),
  198.       bfd *abfd AND
  199.       unsigned long insn AND
  200.       unsigned long value AND
  201.       unsigned short r_type AND
  202.       unsigned short r_field AND
  203.       unsigned short r_format)
  204. {
  205.     unsigned long const_part; /* part of the instruction that does not change */
  206.     unsigned long rebuilt_part;
  207.  
  208.     switch ( r_format ) {
  209.     case 11: {
  210.         unsigned w1, w;
  211.  
  212.         const_part = insn & 0xffffe002;
  213.         dis_assemble_12(value,&w1,&w);
  214.         rebuilt_part = (w1 << 2) | w;
  215.         return const_part | rebuilt_part;
  216.     }
  217.  
  218.     case 12: {
  219.         unsigned w1, w;
  220.  
  221.         const_part = insn & 0xffffe002;
  222.         dis_assemble_12(value,&w1,&w);
  223.         rebuilt_part = (w1 << 2) | w;
  224.         return const_part | rebuilt_part;
  225.     }
  226.  
  227.     case 14:
  228.         const_part = insn & 0xffffc000;
  229.         low_sign_unext(value,14,&rebuilt_part);
  230.         return const_part | rebuilt_part;
  231.  
  232.     case 17: {
  233.         unsigned w1, w2, w;
  234.  
  235.         const_part = insn & 0xffe0e002;
  236.         dis_assemble_17(value,&w1,&w2,&w);
  237.         rebuilt_part = (w2 << 2) | (w1 << 16) | w;
  238.         return const_part | rebuilt_part;
  239.     }
  240.  
  241.     case 21:
  242.         const_part = insn & 0xffe00000;
  243.         dis_assemble_21(value,&rebuilt_part);
  244.         return const_part | rebuilt_part;
  245.  
  246.     case 32:
  247.         const_part = 0;
  248.         return value;
  249.         
  250.     default:
  251.         fprintf(stderr,"Relocation problem : ");
  252.         fprintf(stderr,"Unrecognized reloc type %d (fmt=%d,fld=%d), in module %s\n",
  253.             r_type, r_format, r_field, abfd->filename); 
  254.     }
  255.     return insn;
  256. }
  257.  
  258. static unsigned long
  259. DEFUN(hppa_elf_relocate_insn,
  260.       (abfd, input_sect,
  261.        insn, address, symp, sym_value, r_addend,
  262.        r_type, r_format, r_field, pcrel),
  263.       bfd *abfd AND
  264.       asection *input_sect AND
  265.       unsigned long insn AND
  266.       unsigned long address AND
  267.       asymbol *symp AND
  268.       long sym_value AND
  269.       long r_addend AND
  270.       unsigned short r_type AND
  271.       unsigned short r_format AND
  272.       unsigned short r_field AND
  273.       unsigned char pcrel)
  274. {
  275.     unsigned char opcode = get_opcode(insn);
  276.     long constant_value;
  277.     unsigned arg_reloc;
  278.  
  279.     switch ( opcode ) {
  280.         case LDO:
  281.         case LDB:
  282.         case LDH:
  283.         case LDW:
  284.         case LDWM:
  285.         case STB:
  286.         case STH:
  287.         case STW:
  288.         case STWM:
  289.         constant_value = ELF32_HPPA_R_CONSTANT(r_addend);
  290.         BFD_ASSERT(r_format == 14);
  291.  
  292.         if ( pcrel )
  293.             sym_value -= address;
  294.         sym_value = hppa_field_adjust(sym_value,constant_value,r_field);
  295.         return hppa_elf_rebuild_insn(abfd,insn,sym_value,r_type,r_format, r_format);
  296.  
  297.         case COMICLR:
  298.         case SUBI:    /* case SUBIO: */
  299.         case ADDIT:    /* case ADDITO: */
  300.         case ADDI:    /* case ADDIO: */
  301.         BFD_ASSERT(r_format == 11);
  302.  
  303.         constant_value = ((insn & 0x1) << 10) | ((insn & 0xffe) >> 1);
  304.         sym_value = hppa_field_adjust(sym_value,constant_value,r_field);
  305.         return hppa_elf_rebuild_insn(abfd,insn,sym_value,r_type,r_field, r_format);
  306.  
  307.         case LDIL:
  308.         case ADDIL:
  309.         BFD_ASSERT(r_format == 21);
  310.  
  311.         constant_value = assemble_21(insn);
  312.         sym_value = hppa_field_adjust(sym_value,constant_value,r_field);
  313.         return hppa_elf_rebuild_insn(abfd,insn,sym_value,r_type,r_field, r_format);
  314.  
  315.         case BL:
  316.         case BE:
  317.         case BLE:
  318.         arg_reloc = ELF32_HPPA_R_ARG_RELOC(r_addend);
  319.  
  320.         BFD_ASSERT(r_format == 17);
  321.  
  322.         /* XXX computing constant_value is not needed??? */
  323.         constant_value = assemble_17((insn & 0x001f0000) >> 16,
  324.                          (insn & 0x00001ffc) >> 2,
  325.                          insn & 1);
  326.         constant_value = sign_ext(constant_value,17);
  327.         if ( pcrel ) {
  328.             sym_value -=
  329.                 address + input_sect->output_offset
  330.                     + input_sect->output_section->vma;
  331.             sym_value = hppa_field_adjust(sym_value,-8,r_field);
  332.         }
  333.         else
  334.             sym_value = hppa_field_adjust(sym_value, constant_value, r_field);
  335.  
  336.         return hppa_elf_rebuild_insn(abfd,insn,sym_value >> 2,r_type,r_field, r_format);
  337.  
  338.         default:
  339.         if ( opcode == 0 && r_format == 32 ) {
  340.             constant_value = insn;
  341.             sym_value = hppa_field_adjust(sym_value,constant_value,r_field);
  342.             return sym_value;            
  343.         }
  344.         else {
  345.             fprintf(stderr,
  346.                 "Unrecognized opcode 0x%02x (fmt=%x,field=%x)\n",
  347.                 opcode, r_format, r_field);
  348.             return (insn);
  349.         }
  350.     }
  351. }
  352.  
  353. static void
  354. DEFUN(hppa_elf_relocate_unwind_table,
  355.       (abfd, input_sect,
  356.        data, address, symp, sym_value, r_addend,
  357.        r_type, r_format, r_field, pcrel),
  358.       bfd *abfd AND
  359.       asection *input_sect AND
  360.       PTR data AND
  361.       unsigned long address AND
  362.       asymbol *symp AND
  363.       long sym_value AND
  364.       long r_addend AND
  365.       unsigned short r_type AND
  366.       unsigned short r_format AND
  367.       unsigned short r_field AND
  368.       unsigned char pcrel)
  369. {
  370.     bfd_byte  *hit_data    = address + (bfd_byte *)(data);
  371.     long constant_value;
  372.     long start_offset;
  373.     long end_offset;
  374.     long relocated_value;
  375.     int i;
  376.  
  377.     BFD_ASSERT( r_format == 32 );
  378.     BFD_ASSERT( r_field == e_fsel );
  379.     switch ( r_type ) {
  380.         case R_HPPA_UNWIND_ENTRY:
  381.         start_offset = bfd_get_32(abfd, hit_data);
  382.         relocated_value = hppa_field_adjust(sym_value,start_offset,r_field);
  383.         bfd_put_32(abfd, relocated_value ,hit_data);
  384.  
  385.         hit_data += sizeof(unsigned long);
  386.         end_offset = bfd_get_32(abfd, hit_data);
  387.         relocated_value = hppa_field_adjust(sym_value,end_offset,r_field);
  388.         bfd_put_32(abfd, relocated_value ,hit_data);
  389.         break;
  390.  
  391.         case R_HPPA_UNWIND_ENTRIES:
  392.         for ( i = 0; i < r_addend; i++,hit_data += 3*sizeof(unsigned long) ) {
  393.             unsigned int fsize;
  394.             start_offset = bfd_get_32(abfd, hit_data);
  395.             /* Stuff the symbol value into the first word */
  396.             /* of the  unwind descriptor */
  397.             bfd_put_32(abfd, sym_value ,hit_data);
  398.  
  399.             hit_data += sizeof(unsigned long);
  400.             end_offset = bfd_get_32(abfd, hit_data);
  401.             /* We could also compute the ending offset for */
  402.             /* the 2nd word of the unwind entry by */
  403.             /* retrieving the st_size field of the Elf_Sym */
  404.             /* structure stored with this symbol.  We can */
  405.             /* get it with:     */
  406.             /*     e = (elf_symbol_type *)symp    */
  407.             /*    fsize = e->internal_elf_sym.st_size */
  408.  
  409.             fsize = end_offset - start_offset;
  410.             relocated_value = hppa_field_adjust(sym_value,fsize,r_field);
  411.             bfd_put_32(abfd, relocated_value ,hit_data);
  412.  
  413.             /* If this is not the last unwind entry, */
  414.             /* adjust the symbol value. */
  415.             if ( i+1 < r_addend ) {
  416.                 start_offset = bfd_get_32(abfd, hit_data+3*sizeof(unsigned long));
  417.                 sym_value += fsize + start_offset - end_offset;
  418.             }
  419.         }
  420.         break;
  421.  
  422.         default:
  423.         fprintf(stderr,
  424.             "Unrecognized relocation type 0x%02x (fmt=%x,field=%x)\n",
  425.             r_type, r_format, r_field);
  426.     }
  427.     return;
  428. }
  429.  
  430. /* Provided the symbol, returns the value reffed */
  431. static  long
  432. get_symbol_value(symbol)       
  433. asymbol *symbol;
  434. {                                             
  435.     long relocation = 0;
  436.  
  437.     if ( symbol == (asymbol *)NULL )
  438.         relocation = 0;
  439.     else if (symbol->section == &bfd_com_section) {
  440.         relocation = 0;                           
  441.     }
  442.     else {                                      
  443.         relocation = symbol->value +
  444.             symbol->section->output_section->vma +
  445.                 symbol->section->output_offset;
  446.     }                                           
  447.  
  448.     return(relocation);
  449. }
  450.  
  451. /* This function provides a pretty straight-forward mapping between a */
  452. /* base relocation type, format and field into the relocation type */
  453. /* that will be emitted in an object file.  The only wrinkle in the */
  454. /* mapping is that when the T, TR, TL, P, PR, or PL expression */
  455. /* prefixes are involved, the type gets promoted to a *_GOTOFF_* */
  456. /* relocation (in the case of T, TR, and TL) or a PLABEL relocation */
  457. /* (in the case of P, PR, and PL).    */
  458.  
  459. /* NOTE: XXX the T, TR, TL, P, PR, and PL expression prefixes are not */
  460. /* handled yet. */
  461.  
  462. static void
  463.     hppa_elf_gen_reloc_error(base_type,fmt,field)
  464. elf32_hppa_reloc_type base_type;
  465. int fmt;
  466. int field;
  467. {
  468.     fprintf(stderr, "undefined relocation: base=0x%x,fmt=0x%x,field=0x%x\n",
  469.         base_type, fmt, field);
  470. }
  471.  
  472. unsigned char
  473. hppa_elf_gen_reloc_type(base_type, format, field)
  474. elf32_hppa_reloc_type base_type;
  475. int format;
  476. int field;
  477. {
  478. #define UNDEFINED    hppa_elf_gen_reloc_error(base_type,format,field);
  479.  
  480.     elf32_hppa_reloc_type final_type = base_type;
  481.     switch ( base_type ) {
  482.         case R_HPPA:
  483.         switch (format)    {
  484.             case 11:
  485.             switch ( field ) {
  486.                 case e_rsel:
  487.                 final_type = R_HPPA_R11;
  488.                 break;
  489.                 case e_rssel:
  490.                 final_type = R_HPPA_RS11;
  491.                 break;
  492.                 case e_rdsel:
  493.                 final_type = R_HPPA_RD11;
  494.                 break;
  495.                 
  496.                 case e_psel:
  497.                 final_type = R_HPPA_PLABEL_11;
  498.                 break;
  499.                 case e_rpsel:
  500.                 final_type = R_HPPA_PLABEL_R11;
  501.                 break;
  502.                 case e_lpsel:
  503.                 case e_tsel:
  504.                 case e_ltsel:
  505.                 case e_rtsel:
  506.                 
  507.                 case e_fsel:
  508.                 case e_lsel:
  509.                 case e_lrsel:
  510.                 case e_lssel:
  511.                 case e_rrsel:
  512.                 default:
  513.                 UNDEFINED;
  514.                 final_type = base_type;
  515.                 break;
  516.             }
  517.             break;
  518.             case 12:
  519.             UNDEFINED;
  520.             break;
  521.             case 14:
  522.             switch ( field ) {
  523.                 case e_rsel:
  524.                 final_type = R_HPPA_R14;
  525.                 break;
  526.                 case e_rssel:
  527.                 final_type = R_HPPA_RS14;
  528.                 break;
  529.                 case e_rdsel:
  530.                 final_type = R_HPPA_RD14;
  531.                 break;
  532.                 case e_rrsel:
  533.                 final_type = R_HPPA_RR14;
  534.                 break;
  535.                 
  536.                 case e_psel:
  537.                 final_type = R_HPPA_PLABEL_14;
  538.                 break;
  539.                 case e_rpsel:
  540.                 final_type = R_HPPA_PLABEL_R14;
  541.                 break;
  542.                 case e_lpsel:
  543.                 case e_tsel:
  544.                 case e_ltsel:
  545.                 case e_rtsel:
  546.                 
  547.                 case e_fsel:
  548.                 case e_lsel:
  549.                 case e_lssel:
  550.                 case e_ldsel:
  551.                 case e_lrsel:
  552.                 default:
  553.                 UNDEFINED;
  554.                 final_type = base_type;
  555.                 break;
  556.             }
  557.             break;
  558.             case 17:
  559.             switch ( field ) {
  560.                 case e_rsel:
  561.                 final_type = R_HPPA_R17;
  562.                 break;
  563.                 case e_rssel:
  564.                 final_type = R_HPPA_RS17;
  565.                 break;
  566.                 case e_rdsel:
  567.                 final_type = R_HPPA_RD17;
  568.                 break;
  569.                 case e_rrsel:
  570.                 final_type = R_HPPA_RR17;
  571.                 break;
  572.                 case e_fsel:
  573.                 case e_lsel:
  574.                 case e_lssel:
  575.                 case e_ldsel:
  576.                 case e_lrsel:
  577.                 default:
  578.                 UNDEFINED;
  579.                 final_type = base_type;
  580.                 break;
  581.             }
  582.             break;
  583.             case 21:
  584.             switch ( field ) {
  585.                 case e_lsel:
  586.                 final_type = R_HPPA_L21;
  587.                 break;
  588.                 case e_lssel:
  589.                 final_type = R_HPPA_LS21;
  590.                 break;
  591.                 case e_ldsel:
  592.                 final_type = R_HPPA_LD21;
  593.                 break;
  594.                 case e_lrsel:
  595.                 final_type = R_HPPA_LR21;
  596.                 break;
  597.                 case e_lpsel:
  598.                 final_type = R_HPPA_PLABEL_L21;
  599.                 break;
  600.                 case e_rsel:
  601.                 case e_rssel:
  602.                 case e_rdsel:
  603.                 case e_rrsel:
  604.                 case e_fsel:
  605.                 default:
  606.                 UNDEFINED;
  607.                 final_type = base_type;
  608.                 break;
  609.             }
  610.             break;
  611.             case 32:
  612.             switch ( field ) {
  613.                 case e_fsel:
  614.                 final_type = R_HPPA_32;
  615.                 break;
  616.                 case e_psel:
  617.                 final_type = R_HPPA_PLABEL_32;
  618.                 break;
  619.                 default:
  620.                 UNDEFINED;
  621.                 final_type = base_type;
  622.                 break;
  623.             }
  624.             break;
  625.             default:
  626.             UNDEFINED;
  627.             final_type = base_type;
  628.             break;
  629.         }
  630.         break;
  631.         case R_HPPA_GOTOFF:
  632.         switch (format)    {
  633.             case 11:
  634.             switch ( field ) {
  635.                 case e_rsel:
  636.                 final_type = R_HPPA_GOTOFF_R11;
  637.                 break;
  638.                 case e_rssel:
  639.                 final_type = R_HPPA_GOTOFF_RS11;
  640.                 break;
  641.                 case e_rdsel:
  642.                 final_type = R_HPPA_GOTOFF_RD11;
  643.                 break;
  644.                 case e_fsel:
  645.                 final_type = R_HPPA_GOTOFF_11;
  646.                 break;
  647.                 case e_lsel:
  648.                 case e_lrsel:
  649.                 case e_lssel:
  650.                 case e_rrsel:
  651.                 default:
  652.                 UNDEFINED;
  653.                 final_type = base_type;
  654.                 break;
  655.             }
  656.             break;
  657.             case 12:
  658.             UNDEFINED;
  659.             final_type = base_type;
  660.             break;
  661.             case 14:
  662.             switch ( field ) {
  663.                 case e_rsel:
  664.                 final_type = R_HPPA_GOTOFF_R14;
  665.                 break;
  666.                 case e_rssel:
  667.                 final_type = R_HPPA_GOTOFF_RS14;
  668.                 break;
  669.                 case e_rdsel:
  670.                 final_type = R_HPPA_GOTOFF_RD14;
  671.                 break;
  672.                 case e_rrsel:
  673.                 final_type = R_HPPA_GOTOFF_RR14;
  674.                 break;
  675.                 case e_fsel:
  676.                 final_type = R_HPPA_GOTOFF_14;
  677.                 break;
  678.                 case e_lsel:
  679.                 case e_lssel:
  680.                 case e_ldsel:
  681.                 case e_lrsel:
  682.                 default:
  683.                 UNDEFINED;
  684.                 final_type = base_type;
  685.                 break;
  686.             }
  687.             break;
  688.             case 17:
  689.             UNDEFINED;
  690.             final_type = base_type;
  691.             break;
  692.             case 21:
  693.             switch ( field ) {
  694.                 case e_lsel:
  695.                 final_type = R_HPPA_GOTOFF_L21;
  696.                 break;
  697.                 case e_lssel:
  698.                 final_type = R_HPPA_GOTOFF_LS21;
  699.                 break;
  700.                 case e_ldsel:
  701.                 final_type = R_HPPA_GOTOFF_LD21;
  702.                 break;
  703.                 case e_lrsel:
  704.                 final_type = R_HPPA_GOTOFF_LR21;
  705.                 break;
  706.                 case e_rsel:
  707.                 case e_rssel:
  708.                 case e_rdsel:
  709.                 case e_rrsel:
  710.                 case e_fsel:
  711.                 default:
  712.                 UNDEFINED;
  713.                 final_type = base_type;
  714.                 break;
  715.             }
  716.             break;
  717.             case 32:
  718.             UNDEFINED;
  719.             final_type = base_type;
  720.             break;
  721.             default:
  722.             UNDEFINED;
  723.             final_type = base_type;
  724.             break;
  725.         }
  726.         break;
  727.         case R_HPPA_PCREL_CALL:
  728.         switch (format)    {
  729.             case 11:
  730.             switch ( field ) {
  731.                 case e_rsel:
  732.                 final_type = R_HPPA_PCREL_CALL_R11;
  733.                 break;
  734.                 case e_rssel:
  735.                 final_type = R_HPPA_PCREL_CALL_RS11;
  736.                 break;
  737.                 case e_rdsel:
  738.                 final_type = R_HPPA_PCREL_CALL_RD11;
  739.                 break;
  740.                 case e_fsel:
  741.                 final_type = R_HPPA_PCREL_CALL_11;
  742.                 break;
  743.                 case e_lsel:
  744.                 case e_lrsel:
  745.                 case e_lssel:
  746.                 case e_rrsel:
  747.                 default:
  748.                 UNDEFINED;
  749.                 final_type = base_type;
  750.                 break;
  751.             }
  752.             break;
  753.             case 12:
  754.             UNDEFINED;
  755.             final_type = base_type;
  756.             break;
  757.             case 14:
  758.             switch ( field ) {
  759.                 case e_rsel:
  760.                 final_type = R_HPPA_PCREL_CALL_R14;
  761.                 break;
  762.                 case e_rssel:
  763.                 final_type = R_HPPA_PCREL_CALL_RS14;
  764.                 break;
  765.                 case e_rdsel:
  766.                 final_type = R_HPPA_PCREL_CALL_RD14;
  767.                 break;
  768.                 case e_rrsel:
  769.                 final_type = R_HPPA_PCREL_CALL_RR14;
  770.                 break;
  771.                 case e_fsel:
  772.                 final_type = R_HPPA_PCREL_CALL_14;
  773.                 break;
  774.                 case e_lsel:
  775.                 case e_lssel:
  776.                 case e_ldsel:
  777.                 case e_lrsel:
  778.                 default:
  779.                 UNDEFINED;
  780.                 final_type = base_type;
  781.                 break;
  782.             }
  783.             break;
  784.             case 17:
  785.             switch ( field ) {
  786.                 case e_rsel:
  787.                 final_type = R_HPPA_PCREL_CALL_R17;
  788.                 break;
  789.                 case e_rssel:
  790.                 final_type = R_HPPA_PCREL_CALL_RS17;
  791.                 break;
  792.                 case e_rdsel:
  793.                 final_type = R_HPPA_PCREL_CALL_RD17;
  794.                 break;
  795.                 case e_rrsel:
  796.                 final_type = R_HPPA_PCREL_CALL_RR17;
  797.                 break;
  798.                 case e_fsel:
  799.                 final_type = R_HPPA_PCREL_CALL_17;
  800.                 break;
  801.                 case e_lsel:
  802.                 case e_lssel:
  803.                 case e_ldsel:
  804.                 case e_lrsel:
  805.                 default:
  806.                 UNDEFINED;
  807.                 final_type = base_type;
  808.                 break;
  809.             }
  810.             break;
  811.             case 21:
  812.             switch ( field ) {
  813.                 case e_lsel:
  814.                 final_type = R_HPPA_PCREL_CALL_L21;
  815.                 break;
  816.                 case e_lssel:
  817.                 final_type = R_HPPA_PCREL_CALL_LS21;
  818.                 break;
  819.                 case e_ldsel:
  820.                 final_type = R_HPPA_PCREL_CALL_LD21;
  821.                 break;
  822.                 case e_lrsel:
  823.                 final_type = R_HPPA_PCREL_CALL_LR21;
  824.                 break;
  825.                 case e_rsel:
  826.                 case e_rssel:
  827.                 case e_rdsel:
  828.                 case e_rrsel:
  829.                 case e_fsel:
  830.                 default:
  831.                 UNDEFINED;
  832.                 final_type = base_type;
  833.                 break;
  834.             }
  835.             break;
  836.             case 32:
  837.             UNDEFINED;
  838.             final_type = base_type;
  839.             break;
  840.             default:
  841.             UNDEFINED;
  842.             final_type = base_type;
  843.             break;
  844.         }
  845.         break;
  846.         case R_HPPA_PLABEL:
  847.         switch (format) {
  848.             case 11:
  849.             switch (field) {
  850.                 case e_fsel:
  851.                 final_type = R_HPPA_PLABEL_11;
  852.                 break;
  853.                 case e_rsel:
  854.                 final_type = R_HPPA_PLABEL_R11;
  855.                 break;
  856.                 default:
  857.                 UNDEFINED;
  858.                 final_type = base_type;
  859.                 break;
  860.             }
  861.             break;
  862.             case 14:
  863.             switch (field) {
  864.                 case e_fsel:
  865.                 final_type = R_HPPA_PLABEL_14;
  866.                 break;
  867.                 case e_rsel:
  868.                 final_type = R_HPPA_PLABEL_R14;
  869.                 break;
  870.                 default:
  871.                 UNDEFINED;
  872.                 final_type = base_type;
  873.                 break;
  874.             }
  875.             break;
  876.             case 21:
  877.             switch (field) {
  878.                 case e_lsel:
  879.                 final_type = R_HPPA_PLABEL_L21;
  880.                 break;
  881.                 default:
  882.                 UNDEFINED;
  883.                 final_type = base_type;
  884.                 break;
  885.             }
  886.             break;
  887.             case 32:
  888.             switch (field) {
  889.                 case e_fsel:
  890.                 final_type = R_HPPA_PLABEL_32;
  891.                 break;
  892.                 default:
  893.                 UNDEFINED;
  894.                 final_type = base_type;
  895.                 break;
  896.             }
  897.             break;
  898.             default:
  899.             UNDEFINED;
  900.             final_type = base_type;
  901.             break;
  902.         }
  903.         case R_HPPA_ABS_CALL:
  904.         switch (format)    {
  905.             case 11:
  906.             switch ( field ) {
  907.                 case e_rsel:
  908.                 final_type = R_HPPA_ABS_CALL_R11;
  909.                 break;
  910.                 case e_rssel:
  911.                 final_type = R_HPPA_ABS_CALL_RS11;
  912.                 break;
  913.                 case e_rdsel:
  914.                 final_type = R_HPPA_ABS_CALL_RD11;
  915.                 break;
  916.                 case e_fsel:
  917.                 final_type = R_HPPA_ABS_CALL_11;
  918.                 break;
  919.                 case e_lsel:
  920.                 case e_lrsel:
  921.                 case e_lssel:
  922.                 case e_rrsel:
  923.                 default:
  924.                 UNDEFINED;
  925.                 final_type = base_type;
  926.                 break;
  927.             }
  928.             break;
  929.             case 12:
  930.             UNDEFINED;
  931.             final_type = base_type;
  932.             break;
  933.             case 14:
  934.             switch ( field ) {
  935.                 case e_rsel:
  936.                 final_type = R_HPPA_ABS_CALL_R14;
  937.                 break;
  938.                 case e_rssel:
  939.                 final_type = R_HPPA_ABS_CALL_RS14;
  940.                 break;
  941.                 case e_rdsel:
  942.                 final_type = R_HPPA_ABS_CALL_RD14;
  943.                 break;
  944.                 case e_rrsel:
  945.                 final_type = R_HPPA_ABS_CALL_RR14;
  946.                 break;
  947.                 case e_fsel:
  948.                 final_type = R_HPPA_ABS_CALL_14;
  949.                 break;
  950.                 case e_lsel:
  951.                 case e_lssel:
  952.                 case e_ldsel:
  953.                 case e_lrsel:
  954.                 default:
  955.                 UNDEFINED;
  956.                 final_type = base_type;
  957.                 break;
  958.             }
  959.             break;
  960.             case 17:
  961.             switch ( field ) {
  962.                 case e_rsel:
  963.                 final_type = R_HPPA_ABS_CALL_R17;
  964.                 break;
  965.                 case e_rssel:
  966.                 final_type = R_HPPA_ABS_CALL_RS17;
  967.                 break;
  968.                 case e_rdsel:
  969.                 final_type = R_HPPA_ABS_CALL_RD17;
  970.                 break;
  971.                 case e_rrsel:
  972.                 final_type = R_HPPA_ABS_CALL_RR17;
  973.                 break;
  974.                 case e_fsel:
  975.                 final_type = R_HPPA_ABS_CALL_17;
  976.                 break;
  977.                 case e_lsel:
  978.                 case e_lssel:
  979.                 case e_ldsel:
  980.                 case e_lrsel:
  981.                 default:
  982.                 UNDEFINED;
  983.                 final_type = base_type;
  984.                 break;
  985.             }
  986.             break;
  987.             case 21:
  988.             switch ( field ) {
  989.                 case e_lsel:
  990.                 final_type = R_HPPA_ABS_CALL_L21;
  991.                 break;
  992.                 case e_lssel:
  993.                 final_type = R_HPPA_ABS_CALL_LS21;
  994.                 break;
  995.                 case e_ldsel:
  996.                 final_type = R_HPPA_ABS_CALL_LD21;
  997.                 break;
  998.                 case e_lrsel:
  999.                 final_type = R_HPPA_ABS_CALL_LR21;
  1000.                 break;
  1001.                 case e_rsel:
  1002.                 case e_rssel:
  1003.                 case e_rdsel:
  1004.                 case e_rrsel:
  1005.                 case e_fsel:
  1006.                 default:
  1007.                 UNDEFINED;
  1008.                 final_type = base_type;
  1009.                 break;
  1010.             }
  1011.             break;
  1012.             case 32:
  1013.             UNDEFINED;
  1014.             final_type = base_type;
  1015.             break;
  1016.             default:
  1017.             UNDEFINED;
  1018.             final_type = base_type;
  1019.             break;
  1020.         }
  1021.         break;
  1022.         case R_HPPA_UNWIND:
  1023.         final_type = R_HPPA_UNWIND_ENTRY;
  1024.         break;
  1025.         default:
  1026.         final_type = base_type;
  1027.         break;
  1028.     }
  1029.  
  1030.     return final_type;
  1031. }
  1032.  
  1033. /* 12.4.4. Derive format from instruction    */
  1034.  
  1035. /*    Given a machine instruction, this function determines its format.    */
  1036. /*    The format can be determined solely from looking at the first six    */
  1037. /*    bits (the major opcode) of the instruction.  Several major opcodes    */
  1038. /*    map to the same format.  Opcodes which do not map to a known format    */
  1039. /*    should probably be reported as an error.                */
  1040.  
  1041. unsigned char
  1042. hppa_elf_insn2fmt(type, insn)
  1043. elf32_hppa_reloc_type type;
  1044. unsigned long insn;
  1045. {
  1046.     unsigned char fmt = 0;    /* XXX: is this a proper default?    */
  1047.     unsigned char op = get_opcode(insn);
  1048.  
  1049.     if ( type == R_HPPA_NONE )
  1050.         fmt = 0;
  1051.     else {
  1052.         switch ( op ) {
  1053.         case ADDI:
  1054.         case ADDIT:
  1055.         case SUBI:
  1056.             fmt = 11;
  1057.             break;
  1058.         case MOVB:
  1059.         case MOVIB:
  1060.         case COMBT:
  1061.         case COMBF:
  1062.         case COMIBT:
  1063.         case COMIBF:
  1064.         case ADDBT:
  1065.         case ADDBF:
  1066.         case ADDIBT:
  1067.         case ADDIBF:
  1068.         case BVB:
  1069.         case BB:
  1070.             fmt = 12;
  1071.             break;
  1072.         case LDO:
  1073.         case LDB:
  1074.         case LDH:
  1075.         case LDW:
  1076.         case LDWM:
  1077.         case STB:
  1078.         case STH:
  1079.         case STW:
  1080.         case STWM:
  1081.             fmt = 14;
  1082.             break;
  1083.         case BL:
  1084.         case BE:
  1085.         case BLE:
  1086.             fmt = 17;
  1087.             break;
  1088.         case LDIL:
  1089.         case ADDIL:
  1090.             fmt = 21;
  1091.             break;
  1092.         default:
  1093.             fmt = 32;
  1094.             break;
  1095.         }
  1096.         
  1097.     }
  1098.     return fmt;
  1099. }
  1100.  
  1101. /* this function is in charge of performing all the HP PA relocations */
  1102. long global_value    = 0;
  1103. long    GOT_value    = 0;    /* XXX:  need to calculate this! For HPUX, GOT == DP */
  1104. asymbol *global_symbol = (asymbol *)NULL;
  1105.  
  1106. static bfd_reloc_status_type
  1107. DEFUN(hppa_elf_reloc,(abfd, reloc_entry, symbol_in, data, input_section, output_bfd),
  1108.       bfd *abfd AND
  1109.       arelent *reloc_entry AND
  1110.       asymbol *symbol_in AND
  1111.       PTR data AND
  1112.       asection *input_section AND
  1113.       bfd *output_bfd)
  1114. {
  1115.     unsigned long insn;
  1116.     long    sym_value    = 0;
  1117.     unsigned long unsigned_value;
  1118.     long signed_value;
  1119.  
  1120.     unsigned long addr    = reloc_entry->address ; /*+ input_section->vma*/
  1121.     bfd_byte  *hit_data    = addr + (bfd_byte *)(data);
  1122.     unsigned short r_type    = reloc_entry->howto->type & 0xFF;
  1123.     unsigned short r_field    = e_fsel;
  1124.     boolean r_pcrel        = reloc_entry->howto->pc_relative;
  1125.  
  1126.     /* howto->bitsize contains the format (11, 14, 21, etc) information */
  1127.     unsigned r_format    = reloc_entry->howto->bitsize;
  1128.     long r_addend        = reloc_entry->addend;
  1129.     
  1130.  
  1131.     if (output_bfd) {
  1132.         /* Partial linking - do nothing */
  1133.         reloc_entry->address += input_section->output_offset;
  1134.         return bfd_reloc_ok;
  1135.     }
  1136.  
  1137.     if ( symbol_in && symbol_in->section == &bfd_und_section )
  1138.         return bfd_reloc_undefined;
  1139.  
  1140.     sym_value = get_symbol_value(symbol_in);
  1141.  
  1142.     /* compute value of $global$ if it is there. */
  1143.  
  1144.     if ( global_symbol == (asymbol *)NULL ) {
  1145.         struct elf_backend_data * bed
  1146.             = (struct elf_backend_data *)abfd->xvec->backend_data;
  1147.  
  1148.         if ( bed && bed->global_sym ) {
  1149.             asymbol *gsym = &bed->global_sym->symbol;
  1150.             global_value
  1151.                 = gsym->value
  1152.                     + gsym->section->output_section->vma
  1153.                         + gsym->section->output_offset;
  1154.             GOT_value = global_value;   /* XXX: For HP-UX, GOT==DP */
  1155.             global_symbol = gsym;
  1156.         }
  1157.     }
  1158.  
  1159.     /* get the instruction word */
  1160.     insn = bfd_get_32(abfd, hit_data);
  1161.  
  1162.     /* relocate the value based on the relocation type */
  1163.  
  1164.     /* basic_type_1:    relocation is relative to $global$        */
  1165.     /* basic_type_2:    relocation is relative to the current GOT    */
  1166.     /* basic_type_3:    relocation is an absolute call            */
  1167.     /* basic_type_4:    relocation is an PC-relative call        */
  1168.     /* basic_type_5:    relocation is plabel reference            */
  1169.     /* basic_type_6:    relocation is an unwind table relocation    */
  1170.     /* extended_type:    unimplemented                    */
  1171.     
  1172.     switch ( r_type ) {
  1173.         case R_HPPA_NONE:
  1174.         break;
  1175.         case R_HPPA_32:    /*        Symbol + Addend        32    */
  1176.         
  1177.         r_field = e_fsel;
  1178.         goto do_basic_type_1;
  1179.         case R_HPPA_L21:    /*        L (Symbol, Addend)    21     */
  1180.         r_field = e_lsel;
  1181.         goto do_basic_type_1;
  1182.         case R_HPPA_R11:    /*        R (Symbol, Addend)    11     */
  1183.         r_field = e_rsel;
  1184.         goto do_basic_type_1;
  1185.         case R_HPPA_R14:    /*        R (Symbol, Addend)    14    */
  1186.         r_field = e_rsel;
  1187.         goto do_basic_type_1;
  1188.         case R_HPPA_R17:    /*        R (Symbol, Addend)    17     */
  1189.         r_field = e_rsel;
  1190.         goto do_basic_type_1;
  1191.         case R_HPPA_LS21:    /*        LS(Symbol, Addend)    21    */
  1192.         r_field = e_lssel;
  1193.         goto do_basic_type_1;
  1194.         case R_HPPA_RS11:    /*        RS(Symbol, Addend)    11    */
  1195.         r_field = e_rssel;
  1196.         goto do_basic_type_1;
  1197.         case R_HPPA_RS14:    /*        RS(Symbol, Addend)    14    */
  1198.         r_field = e_rssel;
  1199.         goto do_basic_type_1;
  1200.         case R_HPPA_RS17:    /*        RS(Symbol, Addend)    17    */
  1201.         r_field = e_ldsel;
  1202.         goto do_basic_type_1;
  1203.         case R_HPPA_LD21:    /*        LD(Symbol, Addend)    21    */
  1204.         r_field = e_ldsel;
  1205.         goto do_basic_type_1;
  1206.         case R_HPPA_RD11:    /*        RD(Symbol, Addend)    11    */
  1207.         r_field = e_rdsel;
  1208.         goto do_basic_type_1;
  1209.         case R_HPPA_RD14:    /*        RD(Symbol, Addend)    14    */
  1210.         r_field = e_rdsel;
  1211.         goto do_basic_type_1;
  1212.         case R_HPPA_RD17:    /*        RD(Symbol, Addend)    17    */
  1213.         r_field = e_rdsel;
  1214.         goto do_basic_type_1;
  1215.         case R_HPPA_LR21:    /*        LR(Symbol, Addend)    21    */
  1216.         r_field = e_lrsel;
  1217.         goto do_basic_type_1;
  1218.         case R_HPPA_RR14:    /*        RR(Symbol, Addend)    14    */
  1219.         r_field = e_rrsel;
  1220.         goto do_basic_type_1;
  1221.         case R_HPPA_RR17:    /*        RR(Symbol, Addend)    17    */
  1222.         r_field = e_rrsel;
  1223.         
  1224.         do_basic_type_1:
  1225.         insn = hppa_elf_relocate_insn(abfd, input_section, insn, addr,
  1226.                           symbol_in, sym_value, r_addend,
  1227.                           r_type, r_format, r_field, r_pcrel);
  1228.         break;
  1229.         
  1230.         case R_HPPA_GOTOFF_11:        /*    Symbol - GOT + Addend    11    */
  1231.         r_field = e_fsel;
  1232.         goto do_basic_type_2;
  1233.         case R_HPPA_GOTOFF_14:        /*    Symbol - GOT + Addend    14    */
  1234.         r_field = e_fsel;
  1235.         goto do_basic_type_2;
  1236.         case R_HPPA_GOTOFF_L21:        /*    L (Sym - GOT, Addend)    21    */
  1237.         r_field = e_lsel;
  1238.         goto do_basic_type_2;
  1239.         case R_HPPA_GOTOFF_R11:        /*    R (Sym - GOT, Addend)    11    */
  1240.         r_field = e_rsel;
  1241.         goto do_basic_type_2;
  1242.         case R_HPPA_GOTOFF_R14:        /*    R (Sym - GOT, Addend)    14    */
  1243.         r_field = e_rsel;
  1244.         goto do_basic_type_2;
  1245.         case R_HPPA_GOTOFF_LS21:    /*    LS(Sym - GOT, Addend)    21    */
  1246.         r_field = e_lssel;
  1247.         goto do_basic_type_2;
  1248.         case R_HPPA_GOTOFF_RS11:    /*    RS(Sym - GOT, Addend)    11    */
  1249.         r_field = e_rssel;
  1250.         goto do_basic_type_2;
  1251.         case R_HPPA_GOTOFF_RS14:    /*    RS(Sym - GOT, Addend)    14    */
  1252.         r_field = e_rssel;
  1253.         goto do_basic_type_2;
  1254.         case R_HPPA_GOTOFF_LD21:    /*    LD(Sym - GOT, Addend)    21    */
  1255.         r_field = e_ldsel;
  1256.         goto do_basic_type_2;
  1257.         case R_HPPA_GOTOFF_RD11:    /*    RD(Sym - GOT, Addend)    11    */
  1258.         r_field = e_rdsel;
  1259.         goto do_basic_type_2;
  1260.         case R_HPPA_GOTOFF_RD14:    /*    RD(Sym - GOT, Addend)    14    */
  1261.         r_field = e_rdsel;
  1262.         goto do_basic_type_2;
  1263.         case R_HPPA_GOTOFF_LR21:    /*    LR(Sym - GOT, Addend)    21    */
  1264.         r_field = e_lrsel;
  1265.         goto do_basic_type_2;
  1266.         case R_HPPA_GOTOFF_RR14:    /*    RR(Sym - GOT, Addend)    14    */
  1267.         r_field = e_rrsel;
  1268.         do_basic_type_2:
  1269.         sym_value -= GOT_value;
  1270.         insn = hppa_elf_relocate_insn(abfd, input_section, insn, addr,
  1271.                           symbol_in, sym_value, r_addend,
  1272.                           r_type, r_format, r_field, r_pcrel);
  1273.         break;
  1274.         
  1275.         case R_HPPA_ABS_CALL_11:    /*    Symbol + Addend        11    */
  1276.         r_field = e_fsel;
  1277.         goto do_basic_type_3;
  1278.         case R_HPPA_ABS_CALL_14:    /*    Symbol + Addend        14    */
  1279.         r_field = e_fsel;
  1280.         goto do_basic_type_3;
  1281.         case R_HPPA_ABS_CALL_17:    /*    Symbol + Addend        17    */
  1282.         r_field = e_fsel;
  1283.         goto do_basic_type_3;
  1284.         case R_HPPA_ABS_CALL_L21:    /*    L (Symbol, Addend)    21     */
  1285.         r_field = e_lsel;
  1286.         goto do_basic_type_3;
  1287.         case R_HPPA_ABS_CALL_R11:    /*    R (Symbol, Addend)    11     */
  1288.         r_field = e_rsel;
  1289.         goto do_basic_type_3;
  1290.         case R_HPPA_ABS_CALL_R14:    /*    R (Symbol, Addend)    14    */
  1291.         r_field = e_rsel;
  1292.         goto do_basic_type_3;
  1293.         case R_HPPA_ABS_CALL_R17:    /*    R (Symbol, Addend)    17     */
  1294.         r_field = e_rsel;
  1295.         goto do_basic_type_3;
  1296.         case R_HPPA_ABS_CALL_LS21:    /*    LS(Symbol, Addend)    21    */
  1297.         r_field = e_lssel;
  1298.         goto do_basic_type_3;
  1299.         case R_HPPA_ABS_CALL_RS11:    /*    RS(Symbol, Addend)    11    */
  1300.         r_field = e_lssel;
  1301.         goto do_basic_type_3;
  1302.         case R_HPPA_ABS_CALL_RS14:    /*    RS(Symbol, Addend)    14    */
  1303.         r_field = e_rssel;
  1304.         goto do_basic_type_3;
  1305.         case R_HPPA_ABS_CALL_RS17:    /*    RS(Symbol, Addend)    17    */
  1306.         r_field = e_rssel;
  1307.         goto do_basic_type_3;
  1308.         case R_HPPA_ABS_CALL_LD21:    /*    LD(Symbol, Addend)    21    */
  1309.         r_field = e_ldsel;
  1310.         goto do_basic_type_3;
  1311.         case R_HPPA_ABS_CALL_RD11:    /*    RD(Symbol, Addend)    11    */
  1312.         r_field = e_rdsel;
  1313.         goto do_basic_type_3;
  1314.         case R_HPPA_ABS_CALL_RD14:    /*    RD(Symbol, Addend)    14    */
  1315.         r_field = e_rdsel;
  1316.         goto do_basic_type_3;
  1317.         case R_HPPA_ABS_CALL_RD17:    /*    RD(Symbol, Addend)    17    */
  1318.         r_field = e_rdsel;
  1319.         goto do_basic_type_3;
  1320.         case R_HPPA_ABS_CALL_LR21:    /*    LR(Symbol, Addend)    21    */
  1321.         r_field = e_lrsel;
  1322.         goto do_basic_type_3;
  1323.         case R_HPPA_ABS_CALL_RR14:    /*    RR(Symbol, Addend)    14    */
  1324.         r_field = e_rrsel;
  1325.         goto do_basic_type_3;
  1326.         case R_HPPA_ABS_CALL_RR17:    /*    RR(Symbol, Addend)    17    */
  1327.         r_field = e_rrsel;
  1328.         do_basic_type_3:
  1329.         insn = hppa_elf_relocate_insn(abfd, input_section, insn, addr,
  1330.                           symbol_in, sym_value, r_addend,
  1331.                           r_type, r_format, r_field, r_pcrel);
  1332.         break;
  1333.         
  1334.         case R_HPPA_PCREL_CALL_11:    /*    Symbol - PC + Addend    11    */
  1335.         r_field = e_fsel;
  1336.         goto do_basic_type_4;
  1337.         case R_HPPA_PCREL_CALL_14:    /*    Symbol - PC + Addend    14    */
  1338.         r_field = e_fsel;
  1339.         goto do_basic_type_4;
  1340.         case R_HPPA_PCREL_CALL_17:    /*    Symbol - PC + Addend    17    */
  1341.         r_field = e_fsel;
  1342.         goto do_basic_type_4;
  1343.         case R_HPPA_PCREL_CALL_L21:    /*    L (Symbol - PC, Addend)    21     */
  1344.         r_field = e_lsel;
  1345.         goto do_basic_type_4;
  1346.         case R_HPPA_PCREL_CALL_R11:    /*    R (Symbol - PC, Addend)    11     */
  1347.         r_field = e_rsel;
  1348.         goto do_basic_type_4;
  1349.         case R_HPPA_PCREL_CALL_R14:    /*    R (Symbol - PC, Addend)    14    */
  1350.         r_field = e_rsel;
  1351.         goto do_basic_type_4;
  1352.         case R_HPPA_PCREL_CALL_R17:    /*    R (Symbol - PC, Addend)    17     */
  1353.         r_field = e_rsel;
  1354.         goto do_basic_type_4;
  1355.         case R_HPPA_PCREL_CALL_LS21:    /*    LS(Symbol - PC, Addend)    21    */
  1356.         r_field = e_lssel;
  1357.         goto do_basic_type_4;
  1358.         case R_HPPA_PCREL_CALL_RS11:    /*    RS(Symbol - PC, Addend)    11    */
  1359.         r_field = e_rssel;
  1360.         goto do_basic_type_4;
  1361.         case R_HPPA_PCREL_CALL_RS14:    /*    RS(Symbol - PC, Addend)    14    */
  1362.         r_field = e_rssel;
  1363.         goto do_basic_type_4;
  1364.         case R_HPPA_PCREL_CALL_RS17:    /*    RS(Symbol - PC, Addend)    17    */
  1365.         r_field = e_rssel;
  1366.         goto do_basic_type_4;
  1367.         case R_HPPA_PCREL_CALL_LD21:    /*    LD(Symbol - PC, Addend)    21    */
  1368.         r_field = e_ldsel;
  1369.         goto do_basic_type_4;
  1370.         case R_HPPA_PCREL_CALL_RD11:    /*    RD(Symbol - PC, Addend)    11    */
  1371.         r_field = e_rdsel;
  1372.         goto do_basic_type_4;
  1373.         case R_HPPA_PCREL_CALL_RD14:    /*    RD(Symbol - PC, Addend)    14    */
  1374.         r_field = e_rdsel;
  1375.         goto do_basic_type_4;
  1376.         case R_HPPA_PCREL_CALL_RD17:    /*    RD(Symbol - PC, Addend)    17    */
  1377.         r_field = e_rdsel;
  1378.         goto do_basic_type_4;
  1379.         case R_HPPA_PCREL_CALL_LR21:    /*    LR(Symbol - PC, Addend)    21    */
  1380.         r_field = e_lrsel;
  1381.         goto do_basic_type_4;
  1382.         case R_HPPA_PCREL_CALL_RR14:    /*    RR(Symbol - PC, Addend)    14    */
  1383.         r_field = e_rrsel;
  1384.         goto do_basic_type_4;
  1385.         case R_HPPA_PCREL_CALL_RR17:    /*    RR(Symbol - PC, Addend)    17    */ /* #69 */
  1386.         r_field = e_rrsel;
  1387.         do_basic_type_4:
  1388.         insn = hppa_elf_relocate_insn(abfd, input_section, insn, addr,
  1389.                           symbol_in, sym_value, r_addend,
  1390.                           r_type, r_format, r_field, r_pcrel);
  1391.         break;
  1392.         
  1393.         case R_HPPA_PLABEL_32:
  1394.         case R_HPPA_PLABEL_11:
  1395.         case R_HPPA_PLABEL_14:
  1396.         r_field = e_fsel;
  1397.         goto do_basic_type_5;
  1398.         case R_HPPA_PLABEL_L21:
  1399.         r_field = e_lsel;
  1400.         goto do_basic_type_5;
  1401.         case R_HPPA_PLABEL_R11:
  1402.         case R_HPPA_PLABEL_R14:
  1403.         r_field = e_rsel;
  1404.         do_basic_type_5:
  1405.         insn = hppa_elf_relocate_insn(abfd, input_section, insn, addr,
  1406.                           symbol_in, sym_value, r_addend,
  1407.                           r_type, r_format, r_field, r_pcrel);
  1408.         break;
  1409.         
  1410.         case R_HPPA_UNWIND_ENTRY:
  1411.         case R_HPPA_UNWIND_ENTRIES:
  1412.         hppa_elf_relocate_unwind_table(abfd, input_section, data, addr,
  1413.                            symbol_in, sym_value, r_addend,
  1414.                            r_type, r_format, r_field, r_pcrel);
  1415.         return (bfd_reloc_ok);
  1416.         
  1417.         case R_HPPA_PUSH_CONST:        /*    push Addend            -   -    */
  1418.         case R_HPPA_PUSH_SYM:        /*    push Symbol            -   -    */
  1419.         case R_HPPA_PUSH_GOT:        /*    push GOT            -   -    */
  1420.         case R_HPPA_PUSH_PC:        /*    push PC                -   -    */
  1421.         case R_HPPA_PUSH_PROC:        /*    push Symbol            -   -    */
  1422.         case R_HPPA_PUSH_PLABEL:    /*    [TBD]                -   -    */
  1423.         case R_HPPA_MAX:        /*    pop A and B, push max(B,A)    -   -    */
  1424.         case R_HPPA_MIN:        /*    pop A and B, push min(B,A)    -   -    */
  1425.         case R_HPPA_ADD:        /*    pop A and B, push B + A        -   -    */
  1426.         case R_HPPA_SUB:        /*    pop A and B, push B - A        -   -    */
  1427.         case R_HPPA_MULT:        /*    pop A and B, push B * A        -   -    */
  1428.         case R_HPPA_DIV:        /*    pop A and B, push B / A        -   -    */
  1429.         case R_HPPA_MOD:        /*    pop A and B, push B % A        -   -    */
  1430.         case R_HPPA_AND:        /*    pop A and B, push B & A        -   -    */
  1431.         case R_HPPA_OR:            /*    pop A and B, push B | A        -   -    */
  1432.         case R_HPPA_XOR:        /*    pop A and B, push B ^ A        -   -    */
  1433.         case R_HPPA_NOT:        /*    pop A, push ~A            -   -    */
  1434.         case R_HPPA_LSHIFT:        /*    pop A, push A << Addend        -   -    */
  1435.         case R_HPPA_ARITH_RSHIFT:    /*    pop A, push A >> Addend        -   -    */
  1436.         case R_HPPA_LOGIC_RSHIFT:    /*    pop A, push A >> Addend        -   -    */
  1437.         case R_HPPA_EXPR_F:        /*    pop A, push A + Addend        L   -    */
  1438.         case R_HPPA_EXPR_L:        /*    pop A, push L(A,Addend)        L   -    */
  1439.         case R_HPPA_EXPR_R:        /*    pop A, push R(A,Addend)        R   -    */
  1440.         case R_HPPA_EXPR_LS:        /*    pop A, push LS(A,Addend)    LS  -    */
  1441.         case R_HPPA_EXPR_RS:        /*    pop A, push RS(A,Addend)    RS  -    */
  1442.         case R_HPPA_EXPR_LD:        /*    pop A, push LD(A,Addend)    LD  -    */
  1443.         case R_HPPA_EXPR_RD:        /*    pop A, push RD(A,Addend)    RD  -    */
  1444.         case R_HPPA_EXPR_LR:        /*    pop A, push LR(A,Addend)    LR  -    */
  1445.         case R_HPPA_EXPR_RR:        /*    pop A, push RR(A,Addend)    RR  -    */
  1446.         
  1447.         case R_HPPA_EXPR_32:        /*    pop                -   32    */
  1448.         case R_HPPA_EXPR_21:        /*    pop                -   21    */
  1449.         case R_HPPA_EXPR_11:        /*    pop                -   11    */
  1450.         case R_HPPA_EXPR_14:        /*    pop                -   14    */
  1451.         case R_HPPA_EXPR_17:        /*    pop                -   17    */
  1452.         case R_HPPA_EXPR_12:        /*    pop                -   12    */
  1453.         fprintf(stderr, "Relocation problem: ");
  1454.         fprintf(stderr,"Unimplemented reloc type %d, in module %s\n",
  1455.             r_type,abfd->filename);
  1456.         return(bfd_reloc_notsupported);
  1457.         default:
  1458.         fprintf(stderr,"Relocation problem : ");
  1459.         fprintf(stderr,"Unrecognized reloc type %d, in module %s\n",
  1460.             r_type,abfd->filename); 
  1461.         return (bfd_reloc_dangerous);
  1462.     }
  1463.  
  1464.     /* update the instruction word */
  1465.     bfd_put_32(abfd, insn ,hit_data);
  1466.  
  1467.     return (bfd_reloc_ok);
  1468.  
  1469. }
  1470.  
  1471. static reloc_howto_type *
  1472. elf_hppa_reloc_type_lookup (arch, code)
  1473.      bfd_arch_info_type *arch;
  1474.      bfd_reloc_code_real_type code;
  1475. {
  1476.   /* @@ This is all assuming the use of the HP-specific enum, not the general
  1477.      BFD one.  This should be fixed.  */
  1478.  
  1479.   if ((int) code < (int) R_HPPA_UNIMPLEMENTED)
  1480.     return &elf_hppa_howto_table[(int) code];
  1481.  
  1482.   return (reloc_howto_type *)0;
  1483. }
  1484. #define elf_bfd_reloc_type_lookup    elf_hppa_reloc_type_lookup
  1485.  
  1486. static void
  1487. DEFUN (elf_info_to_howto, (abfd, cache_ptr, dst),
  1488.        bfd *abfd AND
  1489.        arelent *cache_ptr AND
  1490.        Elf_Internal_Rela *dst)
  1491. {
  1492.   abort ();
  1493. }
  1494.  
  1495. #define TARGET_BIG_SYM        elf32_hppa_vec
  1496. #define TARGET_BIG_NAME        "elf32-hppa"
  1497. #define ELF_ARCH        bfd_arch_hppa
  1498.  
  1499. #include "elf32-target.h"
  1500.